/*
 *
 * Copyright 2001 Sun Microsystems, Inc. All Rights Reserved.
 * 
 * This software is the proprietary information of Sun 
 * Microsystems, Inc.  Use is subject to license terms.
 * 
 */
/**
 * The TextListener class implements the MessageListener 
 * interface by defining an onMessage method that displays 
 * the contents of a TextMessage.
 *
 * This class acts as the listener for the SimpleTopicSubscriber
 * class.
 */
package sbc.jms;

import javax.jms.*;

public class FabrikListener implements MessageListener {

    /**
     * Casts the message to a TextMessage and displays its text.
     *
     * @param message     the incoming message
     */
    public void onMessage(Message message) {
        ObjectMessage msg = null;
            
        try {
            if (message instanceof ObjectMessage) {
                msg = (ObjectMessage) message;
                System.out.println("Reading message: " +
                    msg.getObject().toString());
            } else {
                System.out.println("Message of wrong type: " +
                    message.getClass().getName());
            }
        } catch (JMSException e) {
            System.out.println("JMSException in onMessage(): " +
                e.toString());
        } catch (Throwable t) {
            System.out.println("Exception in onMessage():" +
                t.getMessage());
        }
    }
}
